import { ColumnProps } from "@/components/ProTable/interface";
import { configValueOptionTypeEnum, treeDataTypeEnum } from "@/config/enums/serviceDict.ts";

export function config(types: any[], fieldTypes: any[]) {
    const columns: ColumnProps[] = [
        { type: "selection", fixed: "left", width: 80 },
        { type: "index", label: "#", width: 80 },
        // { type: "expand", label: "Expand", width: 100 },
        {
            prop: "type",
            label: "类型",
            width: 120,
            enum: types,
            fieldNames: {
                label: "name",
                value: "type"
            },
            search: { el: "select", props: { placeholder: "配置类型", style: "width: 120px;" } }
        },
        {
            prop: "name",
            label: "名称",
            width: 180,
            search: { el: "input", props: { placeholder: "请输入配置名称", style: "width: 180px;" } }
        },
        {
            prop: "code",
            label: "编码",
            width: 180,
            search: { el: "input", props: { placeholder: "请输入配置编码", style: "width: 180px;" } }
        },
        {
            prop: "field_type",
            label: "字段类型",
            width: 150,
            enum: fieldTypes,
            fieldNames: {
                label: "name",
                value: "type"
            },
            search: { el: "select", props: { placeholder: "配置字段类型", style: "width: 150px;" } }
        },
        {
            prop: "option_type",
            label: "选项类型",
            width: 100,
            enum: configValueOptionTypeEnum,
            search: { el: "select", props: { placeholder: "选项类型", style: "width: 100px;" } }
        },
        {
            prop: "option_value",
            label: "选项值",
            width: 180,
        },
        {
            prop: "data_source",
            label: "数据源",
            width: 100,
            enum: treeDataTypeEnum,
            search: { el: "select", props: { placeholder: "数据源", style: "width: 100px;" } },
        },
        {
            prop: "value",
            label: "配置值",
            search: { el: "input", props: { placeholder: "请输入配置值", style: "width: 180px;" } }
        },
        {
            prop: "sort",
            label: "排序",
            width: 150
        },
        {
            prop: "status",
            label: "状态",
            width: 100,
            enum: [
                { label: "启用", value: 1 },
                { label: "禁用", value: 0 }
            ],
            search: { el: "select", props: { placeholder: "状态", style: "width: 100px;" } }
        },
        { prop: "operation", label: "操作", fixed: "right", width: 240 }
    ];
    return { columns };
}
